<%--
  Created by IntelliJ IDEA.
  User: 今天要吃三碗饭
  Date: 2025/1/4
  Time: 10:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改密码</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .password-container {
            width: 350px;
            padding: 20px;
            background-color: #fff;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            border-radius: 4px;
        }
        h2 {
            text-align: center;
            margin-bottom: 20px;
        }
        form {
            display: flex;
            flex-direction: column;
        }
        label {
            margin-bottom: 5px;
        }
        input[type="password"],
        input[type="email"] {
            padding: 10px;
            margin-bottom: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        input[type="submit"] {
            padding: 10px 20px;
            background-color: #5cb85c;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        input[type="submit"]:hover {
            background-color: #4cae4c;
        }
        .form-footer {
            text-align: center;
            margin-top: 10px;
        }
        .form-footer a {
            color: #5cb85c;
            text-decoration: none;
        }
        .error-message {
            color: red;
            text-align: center;
            margin-top: 10px;
            display: none;
        }
    </style>
</head>
<body>
<div class="password-container">
    <h2>修改密码</h2>
    <form id="password-form" action="<%=request.getContextPath()%>/modify" method="post">
        <label for="email">邮箱:</label>
        <input type="email" id="email" name="email" required placeholder="请输入您的邮箱地址">

        <label for="new-password">新密码:</label>
        <input type="password" id="new-password" name="new-password" required placeholder="请输入您的新密码">

        <label for="confirm-new-password">确认新密码:</label>
        <input type="password" id="confirm-new-password" name="confirm-new-password" required placeholder="请再次输入您的新密码">

        <input type="submit" value="修改密码">

        <div class="form-footer">
            <a href="">返回</a>
        </div>
    </form>
    <div class="error-message" id="error-message">
        两次输入的密码不一致，请重新输入。
    </div>
</div>

<script>
    document.getElementById('password-form').addEventListener('submit', function(event) {
        const newPassword = document.getElementById('new-password').value;
        const confirmPassword = document.getElementById('confirm-new-password').value;
        const errorMessage = document.getElementById('error-message');

        if (newPassword !== confirmPassword) {
            event.preventDefault(); // 阻止表单提交
            errorMessage.style.display = 'block'; // 显示错误信息
        } else {
            errorMessage.style.display = 'none'; // 隐藏错误信息
        }
    });
</script>
</body>
</html>